#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

oracles = {
    "default": [ ["∃ "]
               , ["∀ skP"]
               , ["Time( $tCont"]
               , ["Corrupt"]
               , ["ValidToken"]
               , ["!KU( ~KG"]
               , ["!KU( ~KS"]
               , ["!KU( ~n"]
               , ["!KU( sign"]
               , ["splitEq"]
               , ["!Phone( "]
               , ["!QRList( "]
               , ["!PhoneKey( "]
               , ["!FederationKey"]
               , ["!SPositive", "!PPositive"]
               , ["!Backend( "]
               , ["!IDTable"]
               , ["!SpaceTime"]
               , ["!PhoneReceived( "]
               , ["!PEph( "]
               , ["!PEphSent( "]
               , ["!LEE"]
               , ["!KU"]
               , ["!Chan"]
               , ["splitEqs"]
               , [("<", "Time")]
               , [("Time", "<"), ("Epoch", "<")]
               , ["not"]
               , ["<"]],
}

lines = sys.stdin.readlines()
lemma = sys.argv[1]
oracle = oracles[lemma] if lemma in oracles else oracles["default"]

results = []
for current in oracle:
    for line in list(lines): # local copy
        for guess in current:
            if len(guess) == 2:
                matched = guess[0] in line and guess[1] not in line
            else:
                matched = guess in line
            if matched:
                num = line.split(":")[0]
                results.append(num)
                lines.remove(line)
                break

not_matched = [l.split(":")[0] for l in lines if l.split(":")[0] not in results]

for num in results:
    print(num)
for num in reversed(not_matched):
   print(num)
